import {defineStore} from 'pinia'
import {reqAddressInfo, reqOrderInfo} from '@/api'
import {AddressType, OrderInfoType} from '@/store/types'
//trade模块的仓库
export const useTradeStore = defineStore('trade', {
    state: () => ({
        //用户地址信息
        address: <AddressType[]>[],
        //商品清单数据
        orderInfo: <OrderInfoType>{}
    }),
    getters: {},
    actions: {
        //获取用户地址信息
        async getUserAddress() {
            let result = await reqAddressInfo()
            if (result.code == 200) {
                this.address = result.data
            }
        },
        //获取商品清单数据
        async getOrderInfo() {
            let result = await reqOrderInfo()
            if (result.code == 200) {
                this.orderInfo = result.data
            }
        }
    }
})
